﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExpressionPlotterControl;
using System.Windows.Forms;
using System.Data;

namespace TubesMetnum4.det
{
    class Soal
    {
        //soal 1
        public Func<double, double> soal1 = x => (Math.Pow(Math.E, -x)) / (1 + Math.Pow(x, 0.5) + Math.Pow(x, 2));
        public static Expression nomor1 = new Expression("2*(e^(-x))/(1+sqrt(x)+x*x)");
        //public static Expression nomor1 = new Expression("2x");
        public static Expression nomor6 = new Expression("(4^(1/2))*1/((1-(sin(x/2)^(1/2))*sin(x)^2)^(1/2))");
        public static Expression nomor7a;
        public static Expression nomor2 = new Expression("1/(1+x)");
        public static Expression nomor3 = new Expression("(e^(-x))/(1+sqrt(x)+x*x)");
        public static Expression nomor4;
        public static Expression nomor5 = new Expression("(e^(-x))/(1+sqrt(x)+x*x)");
        //public static Expression nomor6 = new Expression("(e^(-x))/(1+sqrt(x)+x*x)");
        public static Expression nomor7 = new Expression("(e^(-x))/(1+sqrt(x)+x*x)");
        public static Expression test = new Expression("1/(1+x)");
        public static Expression nomor3a = new Expression("x^3");
        public static Expression nomor3b = new Expression("x");

        //soal 2
        public static double h = 6.6256 * Math.Pow(10, -27);
        public static double c = 2.99792 * Math.Pow(10, 10);
        public static double k = 1.3805 * Math.Pow(10, -16);
        public static double y2 = 1;
        public Func<double, double> soal2 = x => (2 * Math.PI * h * (Math.Pow(c, 2))) / (Math.Pow(y2, 5) * (Math.Exp(h * c / (k * y2 * x)) - 1));

        //soal 3
        public Func<double, double> soal3a = x => Math.Pow(x, 3);
        public Func<double, double> soal3b = x => x;

        //soal 4
        public Dictionary<double, double> C4;
        public Func<double, double> soal4;// = x => (C4[x] - 1) / x;
        public Func<double, double> soal5a;
        public Func<double, double> soal5b;

        //soal 5

        //soal 6

        //soal 7

        //soal voba
        public Dictionary<double, double> C5a;
        public Dictionary<double, double> C5b;

        public Func<double, double> soalcoba = x => Math.Pow(x, 2);


        public Soal()
        {
            C4 = new Dictionary<double, double>();
            C4.Add(400, 1.0980);
            C4.Add(250, 0.7468);
            C4.Add(160, 0.5252);
            C4.Add(120, 0.4259);
            C4.Add(80, 0.3429);
            C4.Add(60, 0.4515);
            C4.Add(40, 0.7043);
            C4.Add(20, 0.8683);
            C4.Add(10, 0.9370);
            C4.Add(1, 0.9940);
            soal4 = x => (C4[x] - 1) / x;
            C5a = new Dictionary<double, double>();
            C5b = new Dictionary<double, double>();
            C5a.Add(1, 74);
            C5a.Add(2,85);
            C5a.Add(3,106);
            C5a.Add(4,115);
            C5a.Add(5,94);
            C5a.Add(6,88);
            C5a.Add(7,91);
            C5a.Add(8,110);
            C5a.Add(9,132);
            C5a.Add(10,142);
            C5b.Add(1,153);
            C5b.Add(2,121);
            C5b.Add(3,80);
            C5b.Add(4,77);
            C5b.Add(5,54);
            C5b.Add(6,42);
            C5b.Add(7,38);
            C5b.Add(8,34);
            C5b.Add(9,45);
            C5b.Add(10,66);
            
        }

        public void setlamda2(double a)
        {
            soal2 = x => (2 * Math.PI * h * (Math.Pow(c, 2))) / (Math.Pow(a, 5) * (Math.Exp(h * c / (k * a * x)) - 1));
            //soal2 = x => a*x;
        }
        public void set7a(double a)
        {
            nomor7a = new Expression("(10*(e^(x/"+a+"))*sin(2*x*"+Math.PI+"/"+a+"))^2");//^(x/"+a+")   *sin (2*"+Math.PI+"*x/"+a+")");
             Console.WriteLine(nomor7a.ExpressionText);
            Console.WriteLine(nomor7a.Evaluate(a));
        }
        public void gensoal()
        {
            soal5a = x => C5a[x];
            soal5b = x => C5b[x];
        }
        public void setsoal(double x)
        {
            nomor4 = new Expression("("+C4[x]+"-1)/x");
        }
    }
}
